		TITLE	LINSYM - Copyright (c) SLR Systems 1994
		SUBTTL	Contains Confidential and Proprietary material

		INCLUDE MACROS
		INCLUDE	CDDATA
		INCLUDE	SEGMENTS
		INCLUDE	MODULES
		INCLUDE	SYMBOLS
		INCLUDE	IO_STRUC

		PUBLIC	LINSYM,LINSYM32,FIX_MY_CSEG,LINSYM_CONT


		.DATA

		EXTERNDEF	LINSYM_FLAGS:BYTE,DEBUG_TYPES_SELECTED:BYTE

		EXTERNDEF	END_OF_RECORD:DWORD,LIN_SIZE:DWORD,LIN_GROUP_GINDEX:DWORD,LIN_SEGMOD_GINDEX:DWORD
		EXTERNDEF	CURNMOD_GINDEX:DWORD

		EXTERNDEF	SEGMOD_GARRAY:STD_PTR_S,CSEG_GARRAY:STD_PTR_S,SYMBOL_GARRAY:STD_PTR_S


		.CODE	PASS1_TEXT

		EXTERNDEF	MYCOMDAT_INSTALL:PROC,LINNUM_CONTINUE:PROC,ERR_RET:PROC

		EXTERNDEF	LINSYM_BEFORE_COMDAT_ERR:ABS,LINSYM_CONT_ERR:ABS


;
;		DB	FLAGS		01H - CLEAR == NEW INSTANCE, SET == CONTINUATION
;
;	  	INDEX	PUBLIC NAME	LNAME REFERENCE TO THIS GUY
;
;					NEXT UP TO MANY BYTES OF DATA
;
;IF WE ARE KEEPING THIS RECORD, LINK IT TO COMDAT RECORD FOR LATER LINKING INTO MODULE...
;


LINSYM32	PROC
		;
		;
		;
		MOV	EAX,MASK BIT_32
		JMP	LINSYM1

LINSYM32	ENDP


LINSYM		PROC
		;
		;ESI IS DATA RECORD
		;
		XOR	EAX,EAX
LINSYM1::
		;
		;THROW-AWAY CRITERIA -
		;
		;	1.  THROW AWAY IF KEEPING LINENUMBERS IS NOT SET
		;	2.  THROW AWAY IF NOT DEBUGGING THIS MODULE
		;	3.  THROW AWAY IF ZERO-LENGTH
		;	4.  THROW AWAY IF NOT KEEPING THIS COMDAT INSTANCE
		;
		GETT	DL,KEEPING_LINNUMS		;1.
		MOV	CL,DEBUG_TYPES_SELECTED

		OR	DL,DL
		JZ	L9$

		AND	CL,MASK FL_DEBUG_LINNUMS
		JZ	L9$

		MOV	LIN_SIZE,EAX
		MOV	AL,[ESI]

		INC	ESI
		MOV	LINSYM_FLAGS,AL

		MOV	ECX,END_OF_RECORD	;3.
		NEXT_INDEX	L0

		SUB	ECX,ESI			;LENGTH OF LINNUM DATA
		JBE	L9$			;JUMP IF NOTHING THERE

		PUSHM	ESI,ECX			;SAVE RECORD PTR

		CALL	MYCOMDAT_INSTALL	;PTR TO MYCOMDAT ECX, EAX IS INDEX
		ASSUME	ECX:PTR MYCOMDAT_STRUCT

LINSYM_CONT	LABEL	PROC

		MOV	EAX,[ECX]._MCD_SYMBOL_GINDEX	;COMDAT DEFINED?
		MOV	DL,[ECX]._MCD_FLAGS

		TEST	EAX,EAX
		JZ	L8$			;ILLEGAL LINES BEFORE FIRST COMDAT...

		AND	DL,MASK MCD_KEEPING_THIS
		JZ	L7$			;SKIP IF NOT KEEPING THIS INSTANCE

		CONVERT	EAX,EAX,SYMBOL_GARRAY

		MOV	EAX,[EAX].SYMBOL_STRUCT._S_CD_SEGMOD_GINDEX
		XOR	EDX,EDX

		MOV	LIN_SEGMOD_GINDEX,EAX
		MOV	LIN_GROUP_GINDEX,EDX
		;
		;MAKE SURE LIN_CSEG IS DONE
		;
		CONVERT	EAX,EAX,SEGMOD_GARRAY

		MOV	CL,[EAX].SEGMOD_STRUCT._SM_FLAGS_2

		AND	CL,MASK SM2_CSEG_DONE
		JNZ	L5$

		CALL	FIX_MY_CSEG
L5$:
		POPM	ECX,EAX

		JMP	LINNUM_CONTINUE

L9$:
		RET

		DOLONG	L0

L8$:
		MOV	AL,LINSYM_BEFORE_COMDAT_ERR
		CALL	ERR_RET
L7$:
		POPM	ECX,EAX

		RET

LINSYM		ENDP


FIX_MY_CSEG	PROC
		;
		;JUST LIKE FIX_MULTI_CSEGS, EXCEPT DON'T LINK TO MODULE YET...
		;
		;
		ASSUME	EAX:PTR SEGMOD_STRUCT

		PUSHM	EDI,EBX

		MOV	CL,[EAX]._SM_FLAGS_2
		MOV	EBX,EAX
		ASSUME	EBX:PTR SEGMOD_STRUCT

		OR	CL,MASK SM2_CSEG_DONE
		MOV	DL,-1

		MOV	[EAX]._SM_FLAGS_2,CL
		SETT	NEED_MDB_RECORD,DL

		MOV	EAX,SIZE CSEG_STRUCT
		TILLP2_POOL_ALLOC		;EAX IS LOG

		MOV	EDI,EAX
		INSTALL_POINTER_GINDEX	CSEG_GARRAY	;AX IS INDEX
		MOV	[EBX]._SM_MODULE_CSEG_GINDEX,EAX

		MOV	EBX,EDI
		ASSUME	EBX:PTR CSEG_STRUCT
		MOV	ECX,SIZE CSEG_STRUCT/4

		XOR	EAX,EAX
		MOV	EDX,CURNMOD_GINDEX

		REP	STOSD

		MOV	[EBX]._CSEG_PARENT_MOD_GINDEX,EDX

		POPM	EBX,EDI

		RET

FIX_MY_CSEG	ENDP


		END

